package com.hoyup.gatewayserver;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
@EnableZuulProxy
@EnableConfigurationProperties
@RestController
@RefreshScope
public class GatewayServerApplication {

	@Value("${gatewayTestInfo}")
	private String gatewayTestInfo;

	@RequestMapping("/test")
	@PreAuthorize("hasRole('USER')")
	public String test() {
		return "gateway: " + gatewayTestInfo;
	}

	public static void main(String[] args) {
		SpringApplication.run(GatewayServerApplication.class, args);
	}
}
